package com.gitee.wsl.time.schedule.ext

import com.gitee.wsl.time.schedule.TimeScheduler
import kotlinx.coroutines.currentCoroutineContext
import kotlinx.coroutines.isActive
import kotlin.time.Instant
import kotlin.time.ExperimentalTime


/**
 * Will execute [block] without any checking of result
 */
@OptIn(ExperimentalTime::class)
suspend inline fun TimeScheduler.doInfinity(block: (Instant) -> Unit) = doWhile {
    block(it)
    currentCoroutineContext().isActive
}